import _request from "../../common/_request";
import {Message} from "element-ui";

let lib_system = {

    module: 'system',

    // 登录
    login: function (account, password, callback) {
        let data = {}
        data.account = account
        data.password = password
        let params = _request._params(this.module, 'login', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        });
    },

    // 登录验证码
    login_sms: function (phone, callback) {
        let data = {}
        data.phone = phone
        let params = _request._params(this.module, 'login_sms', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        });
    },

    // 手机号登录
    check_sms: function (phone, code, callback) {
        let data = {}
        // data.name = name
        data.phone = phone
        data.code = code
        let params = _request._params(this.module, 'check_sms', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        });
    },

    // 非账号登录
    login_m: function (sid,name, phone, callback) {
        let data = {}
        data.sid = sid
        data.name = name
        data.phone = phone
        let params = _request._params(this.module, 'login_m', data);
        _request._post(params, function(response){
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            //回调数据
            callback(response.data)
        });
    },

    // 修改密码
    password: function (password, callback) {
        let data = {}
        data.password = password
        let params = _request._params(this.module, 'password', data);
        _request._post(params, function(response){
            console.log(response)
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }
            //回调数据
            callback(response.data)
        });
    },

}


export default lib_system
